"""
Case Type   : 服务端工具
Case Name   : gs_check 增加指定参数--skip-root-items,后查看提示信息是否准确
Create At   : 2024/1/9
Owner       : qumin20145
Description :
    1、执行命令:gs_check -i CheckFirewall -i CheckOmmUserExist --skip-root-items
Expect      :
    1、执行失败，合理报错
History     :
"""

import os
import unittest
from yat.test import Node
from yat.test import macro
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger


class Tools(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f'-----{os.path.basename(__file__)} start-----')
        self.dbuserNode = Node('dbuser')
        self.constant = Constant()
        self.check_msg = 'ERROR: No check item can be performed, ' \
                         'please confirm the input parameters'

    def test_row_compress(self):
        text = '-----step1:执行命令:gs_check -i CheckFirewall -i ' \
               'CheckOmmUserExist --skip-root-items; expect:执行失败，合理报错-----'
        self.log.info(text)
        check_cmd = f'source {macro.DB_ENV_PATH};gs_check -i CheckFirewall ' \
            f'-i CheckOmmUserExist --skip-root-items'
        self.log.info(check_cmd)
        msg = self.dbuserNode.sh(check_cmd).result()
        self.log.info(msg)
        self.assertIn(self.check_msg, msg, '执行失败:' + text)

    def tearDown(self):
        text = '-----无需清理环境-----'
        self.log.info(text)
        self.log.info(f'-----{os.path.basename(__file__)} end-----')
